﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.OleDb;
using System.Configuration;

namespace Smart_Transportation.DAL
{
    public class Data
    {
        public static OleDbCommand cmd;
        public static OleDbConnection con;
        public static OleDbDataReader dr;
        public static OleDbDataAdapter da;
        public static string[] donhang;

        public Data()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public static void connect()
        {
            try
            {
                string str = ConfigurationManager.ConnectionStrings["STConnect"].ConnectionString;
                con = new OleDbConnection(str);
                con.Open();
            }
            catch
            { }
        }
        public static OleDbDataReader Getdata(string query)
        {
            cmd = new OleDbCommand(query, con);
            return cmd.ExecuteReader();
        }
        public static int Update(string query)
        {
            cmd = new OleDbCommand(query, con);
            return cmd.ExecuteNonQuery();
        }
        public static int Count(string query)
        {
            cmd = new OleDbCommand(query, con);
            return (int)cmd.ExecuteScalar();
        }
        public static void DisConect()
        {
            if (con.State == ConnectionState.Open)
            {
                cmd.Dispose();
                con.Dispose();
                con.Close();
            }
        }
    }
}